In Letrec

نویسنده

  • L. Augustsson
چکیده

16 n indicating the number of garbage collections performed during the reduction. Thus-Red runs the program in minimal space and does not improve its performance when supplying more space. In contrast to this, the performance of Lisa critically depends on the available heap-space, with run-times by factor of about three higher than-Red with minimal heap-size, and falling below the run-time of-Red as the heap-size increases. 5 Acknowledgements We are grateful to H.Bll odorn for many valuable discussions about the concept and implementation of Lisa. 15 letrec gen = n: h n:(gen ((+ n) 1) i sel = n::l:if ((eq n) 1) then (hd l) else sel ((? n) 1) (tl l) sieve = l:let p = (hd l), l = (tl l) in letrec filter = l:let e = (hd l); l = (tl l) if eq ((mod e) p) 0 then (filter l) else h e:(filter l) i in h p:(sieve (filter l)) i in (sel 100) (sieve (gen 2)) Figure 4: Prime-sieve of Eratosthenes can use for applicative order reductions essentially the same program except that Consed lists must be replaced by then-else constructs, and head/tail calls must be replaced by applications to the selectors true/false, respectively.-6 1 2 3 heap-size MB] 5 10 15 reduction time sec] minimum memory-size of-Red minimum memory-size of Lisa c c c c c c c c c 7 4 2 1 0 Figure 5: Run-times in relation to provided memory-size of the above example A comparison of the performance gures for this program must take into consideration that Lisa and-Red use diierent heap-management schemes. While Lisa works with a conventional garbage collection scheme,-Red employs reference counting and releases unused heap-space as early as possible. The results are depicted in gure 5 where the symbols represent the values for-Red , and n represent the values for Lisa, with 14 simple y =let A = x::y:(y ((x x) y)) in ((A A) x:x) omega = (x:(x x) x:(x x)) y1 =letrec F = x:(F x)

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Fixing Letrec (reloaded)

The Revised6 Report on Scheme introduces three fundamental changes involving Scheme’s recursive variable binding constructs. First, it standardizes the sequential recursive binding construct, letrec*, which evaluates its initialization expressions in a strict leftto-right order. Second, it specifies that internal and library definitions have letrec* semantics. Third, it prohibits programs from ...

متن کامل

Models of sharing graphs : a categorical semantics of let and letrec

It's coming again, the new collection that this site has. To complete your curiosity, we offer the favorite models of sharing graphs a categorical semantics of let and letrec book as the choice today. This is a book that will show you even new to old thing. Forget it; it will be right for you. Well, when you are really dying of models of sharing graphs a categorical semantics of let and letrec,...

متن کامل

Simulation in the Call-by-Need Lambda-Calculus with Letrec, Case, Constructors, and Seq

This paper shows equivalence of several versions of applicative similarity and contextual approximation, and hence also of applicative bisimilarity and contextual equivalence, in LR, the deterministic call-by-need lambda calculus with letrec extended by data constructors, case-expressions and Haskell’s seq-operator. LR models an untyped version of the core language of Haskell. The use of bisimi...

متن کامل

Robust and Effective Transformation of Letrec

A Scheme letrec expression is easily converted into more primitive constructs via a straightforward transformation given in the Revised Report. This transformation, unfortunately, introduces assignments that can impede the generation of efficient code. This paper presents a more judicious transformation that preserves the semantics of the revised report transformation and also detects invalid r...

متن کامل

Fixing Letrec: A Faithful Yet Efficient Implementation of Scheme's Recursive Binding Construct

A Scheme letrec expression is easily converted into more primitive constructs via a straightforward transformation given in the Revised Report. This transformation, unfortunately, introduces assignments that can impede the generation of efficient code. This article presents a more judicious transformation that preserves the semantics of the revised report transformation and also detects invalid...

متن کامل

Simulation in the Call-by-Need Lambda-Calculus with letrec

This paper shows the equivalence of applicative similarity and contextual approximation, and hence also of bisimilarity and contextual equivalence, in the deterministic call-by-need lambda calculus with letrec. Bisimilarity simplifies equivalence proofs in the calculus and opens a way for more convenient correctness proofs for program transformations. Although this property may be a natural one...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1992